<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<title>产品</title>
		<link type="text/css" href="${ctx}/css/style.css" rel="stylesheet" />
		<link type="text/css" href="${ctx}/css/forms.css" rel="stylesheet" />
		<link type="text/css" href="${ctx}/js/jquery.ui.css" rel="stylesheet" />
		<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
		<script type="text/javascript" src="${ctx}/js/common.js"></script>
		<script type="text/javascript">
			function resetForm() {
				$("#product_name").val("");
			}
			
			function search() {
				$("#form").submit();
			}
			
			function showAll() {
				$("#findNoneIndustry").val("true");
				$("#form").submit();
			}
			
			function showCatalog() {
				$("#findNoneIndustry").val("false");
				$("#form").submit();
			}
			
			function save() {
				$("#form").attr("action", "${ctx}/product/product!saveProductCatalog.action");
				$("#form").submit();
			}
			
			function config(id) {
				$("input:checkbox").attr("checked", "");
				$("input:checkbox[value='" + id + "']").attr("checked", "checked");
				var dateValue = window.showModalDialog("${ctx}/product/product!configDate.action?ids=" + id + "&industryId=${industryId}", null, "dialogWidth:800px;dialogHeight:400px;center:yes;dialogLeft:" + ((window.screen.width - 800) / 2) + "px;dialogTop:" + ((window.screen.height - 400) / 2) + "px;");
				var date = dateValue.split("&");
				$("#form").attr("action", "${ctx}/product/product!saveValidDate.action?beginDate=" + date[0] + "&endDate=" + date[1] + "&beginDateMode=" + date[2]);
				$("#form").submit();
			}
			
			function batchConfig() {
				var ids = "";
				$("input:checkbox:checked").each(function() {
					ids += "&ids=" + $(this).val();
				});
				var dateValue = window.showModalDialog("${ctx}/product/product!configDate.action?industryId=${industryId}" + ids, null, "dialogWidth:800px;dialogHeight:400px;center:yes;dialogLeft:" + ((window.screen.width - 800) / 2) + "px;dialogTop:" + ((window.screen.height - 400) / 2) + "px;");
				var date = dateValue.split("&");
				$("#form").attr("action", "${ctx}/product/product!saveValidDate.action?beginDate=" + date[0] + "&endDate=" + date[1] + "&beginDateMode=" + date[2]);
				$("#form").submit();
			}
		</script>
	</head>
	<body style="margin-top: 20px;">
		<form action="${ctx}/product/product!productList.action" id="form" name="form" method="post">
			<input type="hidden" id="findNoneIndustry" name="findNoneIndustry" value="${findNoneIndustry}" />
			<input type="hidden" id="industryId" name="industryId" value="${industryId}" />
			<table width="95%" border="0" cellpadding="0" cellspacing="0" align="center" style="margin: 0 30px;">
				<tr align="left">
					<td align="left" width="10%">产品名称：</td>
					<td width="30%"><input  id="product_name" name="product.name" value="${product.name}" /></td>
					<td align="right">
						<input type="button" value="查询" onclick="search();" />
						<input type="button" value="重置" onclick="resetForm();" />
						<input type="button" value="保存" onclick="save();" />
						<input type="button" value="显示全部产品" onclick="showAll();" />
						<input type="button" value="显示选中产品" onclick="showCatalog();" />
						<input type="button" value="批量配置" onclick="batchConfig();" />
					</td>
				</tr>
			</table>
			<table border="0" cellpadding="0" cellspacing="0" class="datatable">
				<tr align="center">
					<td nowrap align="center" width="10px"><input type="checkbox" onclick="selectAll(document.getElementsByName('ids'), this.checked);" /></td>
					<td nowrap>产品名称</td>
					<td nowrap>生效日期</td>
					<td nowrap colspan="2" align="center" width="50px">操作</td>
				</tr>
				<c:forEach items="${productList}" var="product">
					<tr align="center">
						<td nowrap><input type="checkbox" name="ids" value="${product.id}"${!empty product.industryName ? ' checked' : ''} /></td>
						<td nowrap>&nbsp;${product.name}</a></td>
						<td nowrap>&nbsp;${product.beginDateShow}</td>
						<td nowrap>
							<ul id="icons" class="ui-widget ui-helper-clearfix">
								<li title="配置" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-wrench" onclick="config('${product.id}')"></span></li>
							</ul>
						</td>
					</tr>
				</c:forEach>
			</table>
		</form>
	</body>
</html>